package org.openea.eap.module.obpm.vo;

import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.Set;

@Schema(description = "管理后台 - 登录用户的权限信息 Response VO，额外包括用户信息和角色列表")
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class AuthPermissionInfoRespVO {

    @Schema(description = "用户信息", requiredMode = Schema.RequiredMode.REQUIRED)
    private UserVO user;

    @Schema(description = "角色标识数组", requiredMode = Schema.RequiredMode.REQUIRED)
    private Set<String> roles;

    @Schema(description = "操作权限数组", requiredMode = Schema.RequiredMode.REQUIRED)
    private Set<String> permissions;

    @Schema(description = "OBPM操作权限数组", requiredMode = Schema.RequiredMode.REQUIRED)
    private Set<String> obpmPermissions;

    @Schema(description = "菜单树", requiredMode = Schema.RequiredMode.REQUIRED)
    private List<org.openea.eap.module.system.controller.admin.auth.vo.AuthPermissionInfoRespVO.MenuVO> menus;

    @Schema(description = "用户信息 VO")
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class UserVO {

        @Schema(description = "用户编号", requiredMode = RequiredMode.REQUIRED, example = "1024")
        private Long id;

        @Schema(description = "Etech用户编号", requiredMode = RequiredMode.NOT_REQUIRED, example = "1024")
        private Long etechUserId;

        @Schema(description = "用户名称", requiredMode = RequiredMode.NOT_REQUIRED, example = "admin")
        private String username;

        @Schema(description = "用户昵称", requiredMode = RequiredMode.REQUIRED, example = "芋道源码")
        private String nickname;

        @Schema(description = "用户头像", requiredMode = RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.jpg")
        private String avatar;

        @Schema(description = "用户状态", requiredMode = RequiredMode.NOT_REQUIRED, example = "")
        private JSONObject userStatus;

        @Schema(description = "用户角色", requiredMode = RequiredMode.NOT_REQUIRED, example = "")
        private JSONObject currentOrg;

        @Schema(description = "邮箱", requiredMode = RequiredMode.NOT_REQUIRED, example = "")
        private String email;

        @Schema(description = "分机号", requiredMode = RequiredMode.NOT_REQUIRED, example = "")
        private String mobile;

        @Schema(description = "用户角色权限", requiredMode = RequiredMode.NOT_REQUIRED, example = "")
        private JSONArray authorities;
    }

    @Schema(description = "是否为开发/管理", requiredMode = RequiredMode.NOT_REQUIRED, example = "")
    private Integer withAdmin;

    @Schema(description = "菜单头部颜色", requiredMode = RequiredMode.NOT_REQUIRED, example = "")
    private String webHeaderColor;

}
